﻿/**************************************************************
 * Project     : Titan Framework
 * Copyright (C) 2011 Microsoft Corp.
 * Author      : Julian Hu
 * Mail        : junhu@microsoft.com
 * Create Date : 2011-05-10
 * Summary     :   
 * 
 * 
 * Modified By : 
 * Date        : 
 * Mail        : 
 * Comment     :   
 * *************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using log4net;

namespace Titan.Logging.Log4netImpl
{
    /// <summary>
    /// 继承ILogger,自定义Log的处理.(扩展log4net)
    /// </summary>
    public class Log4netLogger : Logger
    {
        #region Fields
        private readonly ILog _log4netLogger;
        #endregion

        #region Properties
        public override bool IsDebugEnabled
        {
            get { return _log4netLogger.IsDebugEnabled; }
        }
        public override bool IsInfoEnabled
        {
            get { return _log4netLogger.IsInfoEnabled; }
        }
        public override bool IsWarnEnabled
        {
            get { return _log4netLogger.IsWarnEnabled; }
        }
        public override bool IsErrorEnabled
        {
            get { return _log4netLogger.IsErrorEnabled; }
        }
        public override bool IsFatalEnabled
        {
            get { return _log4netLogger.IsFatalEnabled; }
        }
        #endregion

        #region Constructors

        public Log4netLogger(Type type)
            : base(type)
        {
            _log4netLogger = LogManager.GetLogger(type);
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public override void Debug(string strMsg)
        {
            _log4netLogger.Debug(strMsg);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="msg"></param>
        public override void Debug(Exception exception, string strMsg)
        {
            _log4netLogger.Debug(strMsg, exception);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public override void Info(string strMsg)
        {
            _log4netLogger.Info(strMsg);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="msg"></param>
        public override void Info(Exception exception, string strMsg)
        {
            _log4netLogger.Info(strMsg, exception);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public override void Warn(string strMsg)
        {
            _log4netLogger.Warn(strMsg);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="msg"></param>
        public override void Warn(Exception exception, string strMsg)
        {
            _log4netLogger.Warn(strMsg, exception);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public override void Error(string strMsg)
        {
            _log4netLogger.Error(strMsg);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="msg"></param>
        public override void Error(Exception exception, string strMsg)
        {
            _log4netLogger.Error(strMsg, exception);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public override void Fatal(string strMsg)
        {
            _log4netLogger.Fatal(strMsg);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        /// <param name="msg"></param>
        public override void Fatal(Exception exception, string strMsg)
        {
            _log4netLogger.Fatal(strMsg, exception);
        }

        #endregion
    }
}
